package com.moyu.control;

import com.moyu.activity.PanelGame;
import com.moyu.frame.FrameSavePoint;

import javax.swing.*;
import java.awt.event.*;

public class SaveEnterControl extends KeyAdapter {
    PanelGame panelGame;
    FrameSavePoint frameSavePoint;
    JTextField jTextField;


    public SaveEnterControl(FrameSavePoint frameSavePoint, PanelGame panelGame, JTextField jTextField){
        this.frameSavePoint = frameSavePoint;
        this.panelGame = panelGame;
        this.jTextField = jTextField;
    }

    @Override
    public void keyPressed(KeyEvent e) {
        System.out.println(e.getKeyCode());
        if (e.getKeyCode()==KeyEvent.VK_ENTER){
            if (!jTextField.getText().equals(""))
            //写入文件
            panelGame.addpoint(jTextField.getText());
            //按钮按完后隐藏窗体
            frameSavePoint.setVisible(false);
        }
    }
}
